<script setup lang="ts">
import { ref } from 'vue'
import { useCategorystore } from '@/stores/CategoryStore.ts'
const useCategory = useCategorystore()
let props = defineProps({
  scene: {
    type: Number,
    default: 0,
  },
  type:{
    type:String,
    default:'attr'
}
})
const value1 = ref(useCategory.ID1)
const value2 = ref(useCategory.ID2)
const value3 = ref(useCategory.ID3)
const change1 = () => {
  value2.value = ''
  value3.value = ''
  useCategory.reqCategory2(value1.value)
}
const change2 = () => {
  value3.value = ''
  useCategory.reqCategory3(value2.value)
}
const change3 = async () => {
  await useCategory.reqCategoryList(value1.value, value2.value, value3.value,props.type)
}
</script>

<template>
  <el-card>
    <el-form inline>
      <el-form-item label="一级分类">
        <el-select
          v-model="value1"
          class="m-2"
          placeholder="请选择"
          style="width: 240px"
          @change="change1"
          :disabled="scene === 1"
        >
          <el-option
            v-for="item in useCategory.Category1"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          @change="change2"
          v-model="value2"
          class="m-2"
          placeholder="请选择"
          style="width: 240px"
          :disabled="scene === 1"
        >
          <el-option
            v-for="item in useCategory.Category2"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          @change="change3"
          v-model="value3"
          class="m-2"
          placeholder="请选择"
          style="width: 240px"
          :disabled="scene === 1"
        >
          <el-option
            v-for="item in useCategory.Category3"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<style scoped lang="scss"></style>
